package com.aaa.hospital.util;

import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author ZQ on 2022/2/24
 */



public class DateUtil {
    public static String getDate(){

        // 昨天时间
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");

        Date date = new Date();

        Calendar now = Calendar.getInstance();

        now.setTime(date);

        now.add(Calendar.DAY_OF_MONTH, -1);

        return sdf.format(now.getTime());
    }
    public static String getStringDate(){
        // 今天时间
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        Calendar now = Calendar.getInstance();
        now.setTime(date);

        return sdf.format(now.getTime());
    }
}
